package resource.pojo;

import java.sql.ResultSet;
import java.util.ArrayList;

import models.util.MySqlDataAccessHelper;

public class Department {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer iDDepartment;
	private String departmentName;
	private String location;
	private Integer iDConfigStaticLang;
	private String description;
	private ConfigStaticLang configStaticLang;
	private ArrayList<Employee> allEmployee = new ArrayList<Employee>();
	MySqlDataAccessHelper mysqlHelper = new MySqlDataAccessHelper();

	public MySqlDataAccessHelper getMysqlHelper() {
		return mysqlHelper;
	}

	public void setMysqlHelper(MySqlDataAccessHelper mysqlHelper) {
		this.mysqlHelper = mysqlHelper;
	}


	public Integer getiDConfigStaticLang() {
		return iDConfigStaticLang;
	}

	public void setiDConfigStaticLang(Integer iDConfigStaticLang) {
		this.iDConfigStaticLang = iDConfigStaticLang;
	}

	public Integer getiDDepartment() {
		return iDDepartment;
	}

	public void setiDDepartment(Integer iDDepartment) {
		this.iDDepartment = iDDepartment;
	}

	public String getDepartmentName() {
		return departmentName;
	}

	public void setDepartmentName(String departmentName) {
		this.departmentName = departmentName;
	}

	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public ArrayList<Employee> getAllEmployee() {
		mysqlHelper.open();
		allEmployee.clear();
		try {
			String sql = "select * from employee where IDDepartment="
					+ this.getiDDepartment();
			ResultSet rs = mysqlHelper.executeQuery(sql);
			while (rs.next()) {
				allEmployee.add(new Employee(rs.getString("IDEmployee"), rs
						.getString("UserName"), rs.getString("Password"), rs
						.getString("FullName"), rs.getString("Phone"), rs
						.getDate("Birthday"), rs.getString("Address"), rs
						.getString("Email"), rs.getString("Sex"), rs
						.getString("Position"), rs.getString("IDManager"), rs
						.getInt("IDDepartment"), rs.getInt("IDRole"), rs
						.getString("Description")));
			}
		} catch (Exception e) {
		} finally {
			mysqlHelper.close();
		}
		return allEmployee;
	}

	public void setAllEmployee(ArrayList<Employee> allEmployee) {
		this.allEmployee = allEmployee;
	}

	public ConfigStaticLang getConfigStaticLang() {
//		if (this.iDConfigStaticLang == 0)
//			return configStaticLang = null;
//		mysqlHelper.open();
//		try {
//			String sql = "select * from staticlang where IDConfigStaticLang="
//					+ this.iDConfigStaticLang;
//			ResultSet rs = mysqlHelper.executeQuery(sql);
//			if (rs.next())
//				configStaticLang = new ConfigStaticLang(
//						rs.getInt("IDConfigStaticLang"), rs.getString("VN"),
//						rs.getString("KR"), rs.getString("EN"));
//			else
//				configStaticLang = null;
//		} catch (Exception e) {
//		} finally {
//			mysqlHelper.close();
//		}
		return configStaticLang;
	}

	public void setConfigStaticLang(ConfigStaticLang configStaticLang) {
		this.configStaticLang = configStaticLang;
	}
}
